<%@ page language="java" contentType="text/html;charset=utf-8"
	import="com.zmht.specedu.vo.*,java.util.*"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	/**
	 * @author 张天兴
	 * @since 2009/05/08
	 */

 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<fmt:setBundle basename="PathResource" scope="session" />
<title>聋校备课与语言学习及矫治系统</title>
<link href="<%=request.getContextPath()%>/<fmt:message key='StylePath' />style.css" rel="stylesheet" type="text/css" />
<script src="<%=request.getContextPath()%>/<fmt:message key='JavaScriptPath' />validate.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/<fmt:message key='jquery' />jquery.js"></script>
<script type="text/javascript">

	function chooseitem()
	{
	  
	  var sel1=document.bjclassForm.select1;
	  var sel2=document.bjclassForm.select2;
	  
	  var ops=sel1.options;
	  for(var i=0;i<sel1.options.length;i++){
		if(sel1.options[i].selected){
			sel2.options.add(new Option(sel1.options[i].text,sel1.options[i].value));
	  		sel1.options.remove(i);
	  		i=i-1;
		}
	  }
	}
	
	function cancelitem()
	{
	  var sel1=document.bjclassForm.select1;
	  var sel2=document.bjclassForm.select2;
	  
	  var op=sel2.options;
	  for(var i=0;i<sel2.options.length;i++){
		if(sel2.options[i].selected){
			sel1.options.add(new Option(sel2.options[i].text,sel2.options[i].value));
	  		sel2.options.remove(i);
	  		i=i-1;
		}
	  }
	   
	}
	function chooseallitem()
	{
	  var sel1=document.bjclassForm.select1;
	  var sel2=document.bjclassForm.select2;
	  
	  for(k=0;k<sel1.length;k++)
	  {
	   var op=sel1.options[k];
	   sel2.options.add(new Option(op.text,op.value));
	  }
	  sel1.length=0;
	}
	function cancelallitem()
	{
	
	  var sel1=document.bjclassForm.select1;
	  var sel2=document.bjclassForm.select2;
	  
	  for(k=0;k<sel2.length;k++)
	  {
	   var op=sel2.options[k];
	   sel1.options.add(new Option(op.text,op.value));
	  }
	  sel2.length=0;
	}
	var classNuberSign=false;
	function checkClassNumber(){
		var url = "<%=request.getContextPath()%>/classAction.do?method=checkClassNumberOnlyForAjax";
		var classNumber = document.forms[0].classNumber.value;
		var grade = document.forms[0].grade.value;
		if(grade==""){
			alert("请先选择年级！");
			document.forms[0].grade.focus();
			return false;
		}
		$.ajax({
			 url: url,
			 type: 'POST',
			 dataType: 'text',
			 timeout: 20000,//超时时间设定
			 data:'classNumber='+classNumber+"&gradeNumber="+grade,//参数设置
			 error: function(){alert('error');},//错误处理，隐藏进度条
			 success: function(text){
				 if(text=="false"){
					 addErrorToClassNumberSpan("班号在当前年级下已被使用！");
					 return true;
				 }else{
					 addErrorToClassNumberSpan("");
					 classNuberSign = true;
					 return false;
				 }
			 }
		});
	}
	function check(obj){
	   if(document.forms[0].classType.value==""){
		   window.alert("请选择班级类别！");
		   document.forms[0].classType.focus();
		   return false;
		}
	
		if(document.forms[0].term.value==""){
		   window.alert("请输入学期！必须是数字!");
		   document.forms[0].term.focus();
		   return false;
		}
	    var regw =  /^\+?[1-9][0-9]*$/;　　//正整数 
		if(!regw.test(document.forms[0].term.value)){
			alert("输入的学期有误，必须是数字!");
			return false;
		}	
		  
		if(document.forms[0].grade.value==""){
		   window.alert("请选择年级！");
		   document.forms[0].grade.focus();
		   return false;
		}	
	    if(document.forms[0].select2.length==0){
		   window.alert("请选择老师！至少一位老师!");
		   document.forms[0].select2.focus();
		   return false;
		}       
		var sel2=document.bjclassForm.select2;
		for(k=0;k<sel2.length;k++){
			var op=sel2.options[k];
			op.selected=true;
		}
		if(!classNuberSign){
			if(!checkClassNumber()){
				return false;
			}
		}
		
		return Validator.Validate(obj,3);
	}

	function addErrorToClassNumberSpan(text){
		$("#classNumberSpan").html(text);
		if(text!=""){
			//document.forms[0].classNumber.select();
		}
	}
	function submitForm(){
		if(check(document.forms[0])){
			document.forms[0].submit();
		}
	}
</script>
</head>
<body class="bcolor">
<html:form   method="post" action="classAction.do?method=save">
  <table cellspacing="0" cellpadding="0" width="99%" align="center" border="0">
    <tbody>
      <tr>
        <td width="7"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_01.gif" 
      width="7" /></td>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_05.gif"><table cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td width="30"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_02.gif" 
            width="30" /></td>
                <td align="left" width="200" 
            background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_03.gif">&nbsp;<b>增 加 班 级</b></td>
                <td width="59"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_04.gif" 
            width="59" /></td>
                <td>&nbsp;</td>
              </tr>
            </tbody>
        </table></td>
        <td width="8"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_06.gif" 
      width="8" /></td>
      </tr>
      <tr>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_07.gif"><img height="1" 
      src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />spacer.gif" width="1" /></td>
        <td bgcolor="#f7fbff"><table cellspacing="0" bordercolordark="#ccccff" cellpadding="0" width="100%" bordercolorlight="#ffffff" border="0">
            <tbody>
              <tr bgcolor="#a4c9ec">
                <td align="middle"><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                    <tr>
                      <td width="20%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">班级类别：</td>
                      <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
                         <html:select property="classType" styleClass="boxcopy2"  style="width:104px;">
                             <html:optionsCollection name="list" label="typeName" value="id"/>
                        </html:select>
                        <span class="STYLE4">*</span>
                      </td>
                    </tr>
                </table></td>
              </tr>
              <tr bgcolor="#ffffff">
                <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                    <tr>
                      <td width="20%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">学 期：</td>
                      <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
                      <input name="term" type="text" class="boxcopy2" id="textfield7"  maxlength="8"  style="width:100px;"/>
                    <span class="STYLE4">*</span>(必须是数字,如:2或12)</td>
                    </tr>
                </table></td>
              </tr>
              <tr bgcolor="#ffffff">
                <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                    <tr>
                      <td width="20%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">年 级：</td>
                      <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
                      <html:select name="bjclassForm" property="grade" styleClass="boxcopy2"  style="width:104px;" onchange="checkClassNumber();">
                 <html:optionsCollection name="list2" label="name" value="id"/>                                 
                 </html:select>
                 <span class="STYLE4">*</span>
                      </td>                      
                    </tr>
                </table></td>
              </tr>
              <tr bgcolor="#ffffff">
                <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                    <tr>
                      <td width="20%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">班 号：</td>
                      <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
						<input name="classNumber" type="text" onblur="checkClassNumber();" class="boxcopy2" id="textfield8" maxlength="8" style="width:100px;"/> <span id="classNumberSpan" class="STYLE4"></span></td>
                    </tr>
                </table></td>
              </tr>

              <tr bgcolor="#ffffff">
                <td height="1" bgcolor="#ffffff"></td>
              </tr>
              <tr bgcolor="#ffffff">
                <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                    <tr>
                      <td height="20" align="right" valign="middle" bgcolor="#e6f0f8"><p align="center"><strong>选择教师 </strong><span class="STYLE4">*</span></p></td>
                    </tr>
                </table></td>
              </tr>
              <tr bgcolor="#ffffff">
                <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                    <tr>
                      <td width="40%" height="20" align="right" valign="middle" bgcolor="#FFFFFF"><table width="200" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td align="center"><strong>未被选择的教师姓名</strong></td>
                          </tr>
                          <tr>
                            <td align="right">
	                <html:select property="select1" styleClass="boxcopy2"  style="width:200px;" multiple="8" size="6">
	                <html:optionsCollection name="list3" label="tname" value="teacherId"/>
	                </html:select> 
                            </td>
                          </tr>
                      </table></td>
                      <td width="20%" height="20" align="center" valign="middle" bgcolor="#E6F0F8"><table width="100%" border="0" cellspacing="10" cellpadding="0">
                          <tr>
                            <td align="center"><a href="javascript:chooseitem();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-04.gif" width="63" height="22" border="0" /></a></td>
                          </tr>
                          <tr>
                            <td align="center"><a href="javascript:cancelitem();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-05a.gif" width="63" height="22" border="0" /></a></td>
                          </tr>
                          <tr>
                            <td align="center"><a href="javascript:chooseallitem();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-06.gif" width="63" height="22" border="0" /></a></td>
                          </tr>
                          <tr>
                            <td align="center"><a href="javascript:cancelallitem();" onfocus="this.blur()"> <img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-07.gif" width="63" height="22" border="0" /></a></td>
                          </tr>
                      </table></td>
                      <td width="40%" align="left" valign="middle" bgcolor="#FFFFFF"><table width="200" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td align="center"><strong>已被选择的教师姓名</strong></td>
                          </tr>
                          <tr>
                            <td align="right">
                            <select name="select2" multiple size="6" class="boxcopy2"  style="width:200px;"></select>
                            </td>
                          </tr>
                      </table></td>
                    </tr>
                </table></td>
              </tr>
            </tbody>
          </table>
            <table cellspacing="1" cellpadding="0" width="100%" bgcolor="#ffffff" 
        border="0">
              <tbody>
                <tr>
                  <td align="middle" bgcolor="#e6f0f8"><table cellspacing="0" cellpadding="3" width="100%" border="0">
                      <tbody>
                        <tr>
                          <td width="50%" align="right"><img style="cursor: pointer;" onclick="submitForm();" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-01.gif" width="53" height="22" border="0" /></td>
                          <td width="50%" align="left"><a href="javascript:document.forms[0].reset();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-02.gif" width="53" height="22" border="0" /></a></td>
                        </tr>
                      </tbody>
                  </table></td>
                </tr>
              </tbody>
          </table></td>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_09.gif"><img height="1" 
      src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />spacer.gif" width="1" /></td>
      </tr>
      <tr>
        <td><img height="22" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_10.gif" width="7" /></td>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_11.gif">&nbsp;</td>
        <td><img height="22" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_12.gif" 
  width="8" /></td>
      </tr>
    </tbody>
  </table>
</html:form>
</body>
</html>
 